// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from '@/store/index.js'
// 1.引入element-ui组件
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

// 99999富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor, /* { default global options } */)


// 2.引入index.css
import '@/styles/index.scss'
Vue.use(ElementUI)
Vue.config.productionTip = false

// 添加路由守卫
router.beforeEach((to, from, next) => {
  let token = localStorage.getItem("adminToken")
  if (token) {
    // 验证token，有则继续当前操作
    next();
  } else {
    // 判断跳转的是否登陆页
    if (to.path !== "/login") {
      // this指向改变，使用官方写法
      next({path:'/login'})
    } else {
      // 是则继续当前操作
      next();
    }
  }
})



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
